﻿using DayuCode.Designer.Entity;
using DayuCode.Designer.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DayuCode.Designer.Service
{
    public class DataColumnHandler
    {
        private static string getBaseUrl(string methodName)
        {
            return AppInstance.ApiServer + "api/base/dayucode_dataColumnHandler/" + methodName;
        }

        public static HDataColumn GetDataColumn(long id)
        {
            HDataColumn obj = QHttpClient.Post<HDataColumn>(getBaseUrl("getDataColumn"), new {id = id });
            return obj;
        }

		public static void deleteDataColumn(long id)
		{
			QHttpClient.Execute(getBaseUrl("deleteDataColumn"), new { id = id });
		}

		public static DataColumnsVO getDataColumnsVO(long datatableId)
		{
			DataColumnsVO obj = QHttpClient.Post<DataColumnsVO>(getBaseUrl("getDataColumnsVO"), new { datatableId = datatableId });
			return obj;
		}

		public static HDataColumn saveDataColumn(HDataColumn item)
		{
			HDataColumn obj = QHttpClient.Post<HDataColumn>(getBaseUrl("saveDataColumn"), new { item = item });
			return obj;
		}

		public static HDataColumn getDataColumn(long id)
		{
			HDataColumn obj = QHttpClient.Post<HDataColumn>(getBaseUrl("getDataColumn"), new { id = id });
			return obj;
		}

		public static HDataColumn updateProp(long id, string propName, string value)
		{
			HDataColumn obj = QHttpClient.Post<HDataColumn>(getBaseUrl("updateProp"), new { id = id, propName = propName, value = value });
			return obj;
		}

		public static IList<HDataColumn> getDataColumnsByDataset(long datasetId)
		{
			IList<HDataColumn> obj = QHttpClient.Post<List<HDataColumn>>(getBaseUrl("getDataColumnsByDataset"), new { datasetId = datasetId });
			return obj;
		}
	}
}
